<br>
<% post.comments.forEach(function (comment) { %>
   <p>
     <%= comment.name %>
     <span class="info">回复于<%= comment.time %></span>
   </p>
   <p><%- comment.content %></p>
<% })%>
<% if (user) { %>
<form method="post" action="/comment/<%= post.name %>/<%= post.time.minute %>/<%= post.title %>">
  发布人:<%= user.name %>
  <input type="hidden" name="name" value="<%= user.name %>" /><br />
  <textarea name="content" rows="5" cols="80"></textarea><br />
  <input type="submit" value="留言" />
</form>
<% } else {%>
<form  method="post">
  回应请先 <a href="/login">登录</a>或 <a href="/reg">注册</a>
  <textarea name="content" id="tb" cols="100" rows="10"></textarea>
  <input type="submit" id="sb" value="留言">
</form>
<% } %>
<script>
  window.onload = function () {
    var textarea = document.querySelector('#tb');
    var button = document.querySelector('#sb');
    button.onclick = function(e) {
      e.preventDefault();
      location.href = '/login'
    }
    textarea.onclick = function () {
      location.href = '/login'
    }
  }
</script>